/*Joseph A. Coll
7/8/2023
Cleaning ANES */


use "anes_timeseries_2020_stata_20220210.dta", clear

*Political Interest to Politics/Elections
tab V201005
tab V201005, nol
recode V201005 (1=4 "High") (2=3 "Moderately High") (3=2 "Moderately Low") (-9 4/5 =1 "Low"), gen(poli_int_politics)
label var poli_int_politics "Political Interest"
tab poli_int_politics

*Ideology
tab V201200
tab V201200, nol
recode V201200 (1=1 "V. Lib.") (2=2 "Lib.") (3=3 "S. Lib.") (-9 -8 4 99= 4 "Moderate") (5=5 "S. Cons.") (6=6 "Cons.") (7=7 "V. Cons."), gen(conservativism)
label var conservativism Conservativism
tab conservativism

recode V201200 (1/3=1 "Liberal") (-9 -8 4 99= 2 "Moderate") (5/7=3 "Conservative"), gen(conservativism3)
label var conservativism3 Conservativism
tab conservativism3

*Age
tab V201507x
sum V201507x if V201507x !=-9
recode V201507x (-9=52), gen(age)
label var age Age
tab age

gen age2 =age *age
label var age2 "Age Squared"
tab age2

*Education
tab V201510
tab V201510, nol
tab V201510 if V201510 <95 & V201510 >0
sum V201510 if V201510 <95 & V201510 >0
recode V201510 (1=1 "<HS") (2=2 "HS Grad.") (3=3 "Some Coll.") (-9 -8 4/5 95=4 "Assoc.") (6=5 "Bach.") (7=6 "MA") (8=7 "Adv."), gen(educ)
label var educ Education
tab educ

*Latino
tab V201546
tab V201546, nol
recode V201546 (1=1 "Latino") (-9 -8 2=0 "Not Latino"), gen(hispanic)
replace hispanic = 1 if V201549x ==3
label var hispanic Hispanic
tab hispanic

*Race
tab V201549x
recode V201549x (1=1 "White") (-9 -8 2/6=0 "Not White"), gen(white_non_hispanic)
label var white_non_hispanic "White"
tab white_non_hispanic

tab V201549x
recode V201549x (2=1 "Black") (-9 -8 1 3/6=0 "Not Black"), gen(black_non_hispanic)
label var black_non_hispanic "Black"
tab black_non_hispanic

tab V201549x
recode V201549x (-9 -8 1 4/6=1 "Other Race") (1 2 3=0 "Not Other Race"), gen(other_non_hispanic)
label var other_non_hispanic "Other Race"
tab other_non_hispanic

*Income
tab V202468x
sum V202468x if V202468x >0
clonevar income_mean = V202468x 
recode income_mean (-9/-1=7)
label var income_mean Income
tab income_mean 

*Party
tab V201231x
recode V201231x (1/2=1 "Democrat") (-9/-8 3/7=0 "Not Democrat"), gen(dem_no_lean)
label var dem_no_lean Democrat
tab dem_no_lean

recode V201231x (1/3=1 "Democrat") (-9 -8 4/7=0 "Not Democrat"), gen(dem_w_lean)
label var dem_w_lean "Democrat"
tab dem_w_lean 

recode V201231x (-9 -8 4=1 "Independent") (1/3 5/7=0 "Not Independent"), gen(ind_nolean)
label var ind_nolean"Independent"
tab ind_nolean

recode V201231x (3/5=1 "Independent") (-9/-8 1/2 6/7=0 "Not Independent"), gen(ind_w_lean)
label var ind_w_lean Independent
tab ind_w_lean

recode V201231x (6/7=1 "Republican") (-9/-8 1/5=0 "Not Republican"), gen(rep_no_lean)
label var rep_no_lean Republican
tab rep_no_lean

recode V201231x (5/7=1 "Republican") (-9 -8 1/4=0 "Not Republican"), gen(rep_w_lean)
label var rep_w_lean "Republican"
tab rep_w_lean 

recode V201231x (1=1 "Strong Dem.") (2=2 "Mod. Dem.") (3=3 "Lean Dem.") (4=4 "Independent") (5=5 "Lean Rep.") (6=6 "Mod. Rep.") (7=7 "Strong Rep.") (-9/-8=.), gen(party_scale)
label var party_scale "Party"
tab party_scale 

*Black Feeling Thermometer
tab V202480
sum V202480 if V202480 >-1
recode V202480 (-9/-4=72), gen (ft_black)
label var ft_black "Black Feeling Therm."
tab ft_black 

*Racial resentment
tab V202300 
tab V202300, nol
recode V202300 (1=5 "Agree Strongly") (2=4 "Agree Somewhat") (3=3 "Neither") (4=2 "Disagree Somehwat") (5=1 "Disagree Strongly") (-9/-1=.), gen(racism_nofavors)
label var racism_nofavors "Blacks Should Work w/o Special Favors"
tab racism_nofavors

tab V202301 
tab V202301, nol
recode V202301 (1=1 "Agree Strongly") (2=2 "Agree Somewhat") (3=3 "Neither") (4=4 "Disagree Somehwat") (5=5 "Disagree Strongly") (-9/-1=.), gen(racism_slaverydifficult)
label var racism_slaverydifficult "Slavery/Discrim. Limit Blacks (rev.)"
tab racism_slaverydifficult

tab V202302 
tab V202302, nol
recode  V202302 (1=1 "Agree Strongly") (2=2 "Agree Somewhat") (3=3 "Neither") (4=4 "Disagree Somehwat") (5=5 "Disagree Strongly") (-9/-1=.), gen(racism_dontgetless)
label var racism_dontgetless "Blacks Get Less (rev.)"
tab racism_dontgetless

tab V202303
tab V202303, nol
recode V202303 (1=5 "Agree Strongly") (2=4 "Agree Somewhat") (3=3 "Neither") (4=2 "Disagree Somehwat") (5=1 "Disagree Strongly") (-9/-1=.), gen(racism_blacksshouldtry)
label var racism_blacksshouldtry "Blacks Should Try Harder"
tab racism_blacksshouldtry

gen racism_scale2_1= .
replace racism_scale2_1 = (racism_nofavors + racism_slaverydifficult + racism_dontgetless + racism_blacksshouldtry)-4
label var racism_scale2_1 "Racial Resentment"
tab racism_scale2_1 

*Stereotypes
tab V202516 

	*Hard working
	tab V202515
	tab V202515 if white_non ==1 
	recode V202515 (1=1 "Hard-working") (2=2) (3=3) (4=4 ) (5=5) (6=6) (7=7 "Lazy") (-9/-1=.), gen(stereo_white_lazy)
	label var stereo_white_lazy "White Lazy" 
	tab stereo_white_lazy

	tab V202516
	tab V202516 if white_non ==1 
	recode V202516 (1=1 "Hard-working") (2=2) (3=3) (4=4 ) (5=5) (6=6) (7=7 "Lazy") (-9/-1=.), gen(stereo_black_lazy)
	label var stereo_black_lazy "Black Lazy" 
	tab stereo_black_lazy

	*Differences 
	gen stereo_lazy_black_diff = .
	replace stereo_lazy_black_diff  = stereo_white_lazy - stereo_black_lazy if white_non ==1
	tab stereo_lazy_black_diff
	recode stereo_lazy_black_diff (-6/-1=1 "Black Lazier") (0=0 "Same") (1/6=-1 "White Lazier"), gen(stereo_lazy_black_diff3)
	label var stereo_lazy_black_diff3 "Black Lazier"
	tab stereo_lazy_black_diff3

	*Violent
	tab V202521
	tab V202521 if white_non ==1 
	recode V202521 (1=1 "Peaceful") (2=2) (3=3) (4=4 ) (5=5) (6=6) (7=7 "Violent") (-9/-1=.), gen(stereo_white_violent)
	label var stereo_white_violent "White Violent" 
	tab stereo_white_violent

	recode V202521 (1/3=-1 "Peaceful") (4=0 "Neither") (5/7=1 "Violent") (-9/-1=.), gen(stereo_white_violent3)
	label var stereo_white_violent3 "White Violent" 
	tab stereo_white_violent3

	tab V202522
	tab V202522 if white_non ==1 
	recode V202522 (1=1 "Peaceful") (2=2) (3=3) (4=4 ) (5=5) (6=6) (7=7 "Violent") (-9/-1=.), gen(stereo_black_violent)
	label var stereo_black_violent "Black Violent" 
	tab stereo_black_violent

	recode V202522 (1/3=-1 "Peaceful") (4=0 "Neither") (5/7=1 "Violent") (-9/-1=.), gen(stereo_black_violent3)
	label var stereo_black_violent3 "Black Violent" 
	tab stereo_black_violent3

	*Differences 
	gen stereo_violent_black_diff = .
	replace stereo_violent_black_diff  = stereo_black_violent -  stereo_white_violent if white_non ==1
	label var stereo_violent_black_diff "Black more Violent"	
	tab stereo_violent_black_diff
	clonevar stereo_violent_black_diff_orig = stereo_violent_black_diff
	recode stereo_violent_black_diff (-6/-1=-1 "White More Violent") (0=0 "Same") (1/6=1 "Black More Violent"), gen(stereo_violent_black_diff3)
	tab stereo_violent_black_diff3
	label var stereo_violent_black_diff3 "Black more Violent"	

*Support for Felon Disenfranchisment
tab V201360 
tab V201360, nol
recode V201360 (1=-1 "Opposes FD") (2=1 "Supports FD") (-9 -8 3=0 "Neither"), gen(supports_fd)
label var supports_fd "Supports Felon Disenf."
tab supports_fd

tab V201362x
tab V201362x, nol
recode V201362x (1=1 "Opposes Greatly") (2=2 "Opposes Moderately") (3=3 "Opposes a Little") (-2 4=4 "Neither") (5=5 "Favors a Little") (6=6 "Favors Moderately") (7=7 "Favors Greatly"), gen(supports_fd_scale)
label var supports_fd_scale "Felon Disenf. Support Scale"
tab supports_fd_scale

*White Racial Importance
tab V202499x
tab V202499x, nol
tab V202499x if white_non == 1
recode V202499x (1=5 "Extremely Important") (2=4 "Very Important") (3=3 "Moderately Important") (4=2 "A Little Important") (5=1 "Not at all Important") (-9/-1=.), gen(racial_importance)
label var racial_importance "Racial Importance"
tab racial_importance

*Spending on Crime
tab V201311x 
tab V201311x, nol
recode V201311x (1=5 "Increase a Lot") (2=4 "Increase a Little") (3=3 "Kept the Same") (4=2 "Decreased a Little") (5=1 "Decreased a Lot") (-2 . =3), gen(spending_crime)
label var spending_crime "Wants More Crime Spending"

*State
tab V203001
tab V203001, nol
statastates, abbreviation(V203001)
replace state_name = proper(state_name)
rename V203001 state_abbrev
gen year = 2020

gen perc_black = ""						
replace perc_black = 	"25.64%	"	if state_name == "Alabama"
replace perc_black = 	"2.83%	"	if state_name == "Alaska"
replace perc_black = 	"4.43%	"	if state_name == "Arizona"
replace perc_black = 	"14.94%	"	if state_name == "Arkansas"
replace perc_black = 	"5.36%	"	if state_name == "California"
replace perc_black = 	"3.83%	"	if state_name == "Colorado"
replace perc_black = 	"10.01%	"	if state_name == "Connecticut"
replace perc_black = 	"21.51%	"	if state_name == "Delaware"
replace perc_black = 	"40.91%	"	if state_name == "District Of Columbia"
replace perc_black = 	"14.52%	"	if state_name == "Florida"
replace perc_black = 	"30.60%	"	if state_name == "Georgia"
replace perc_black = 	"1.50%	"	if state_name == "Hawaii"
replace perc_black = 	"0.80%	"	if state_name == "Idaho"
replace perc_black = 	"13.86%	"	if state_name == "Illinois"
replace perc_black = 	"9.39%	"	if state_name == "Indiana"
replace perc_black = 	"4.05%	"	if state_name == "Iowa"
replace perc_black = 	"5.56%	"	if state_name == "Kansas"
replace perc_black = 	"7.94%	"	if state_name == "Kentucky"
replace perc_black = 	"31.18%	"	if state_name == "Louisiana"
replace perc_black = 	"1.84%	"	if state_name == "Maine"
replace perc_black = 	"29.06%	"	if state_name == "Maryland"
replace perc_black = 	"6.50%	"	if state_name == "Massachusetts"
replace perc_black = 	"13.48%	"	if state_name == "Michigan"
replace perc_black = 	"6.88%	"	if state_name == "Minnesota"
replace perc_black = 	"36.44%	"	if state_name == "Mississippi"
replace perc_black = 	"11.26%	"	if state_name == "Missouri"
replace perc_black = 	"0.47%	"	if state_name == "Montana"
replace perc_black = 	"4.81%	"	if state_name == "Nebraska"
replace perc_black = 	"9.40%	"	if state_name == "Nevada"
replace perc_black = 	"1.35%	"	if state_name == "New Hampshire"
replace perc_black = 	"12.42%	"	if state_name == "New Jersey"
replace perc_black = 	"1.81%	"	if state_name == "New Mexico"
replace perc_black = 	"13.66%	"	if state_name == "New York"
replace perc_black = 	"20.19%	"	if state_name == "North Carolina"
replace perc_black = 	"3.36%	"	if state_name == "North Dakota"
replace perc_black = 	"12.35%	"	if state_name == "Ohio"
replace perc_black = 	"7.15%	"	if state_name == "Oklahoma"
replace perc_black = 	"1.86%	"	if state_name == "Oregon"
replace perc_black = 	"10.53%	"	if state_name == "Pennsylvania"
replace perc_black = 	"5.05%	"	if state_name == "Rhode Island"
replace perc_black = 	"24.79%	"	if state_name == "South Carolina"
replace perc_black = 	"1.97%	"	if state_name == "South Dakota"
replace perc_black = 	"15.68%	"	if state_name == "Tennessee"
replace perc_black = 	"11.82%	"	if state_name == "Texas"
replace perc_black = 	"1.14%	"	if state_name == "Utah"
replace perc_black = 	"1.34%	"	if state_name == "Vermont"
replace perc_black = 	"18.28%	"	if state_name == "Virginia"
replace perc_black = 	"3.84%	"	if state_name == "Washington"
replace perc_black = 	"3.61%	"	if state_name == "West Virginia"
replace perc_black = 	"6.22%	"	if state_name == "Wisconsin"
replace perc_black = 	"0.82%	"	if state_name == "Wyoming"
destring perc_black, ignore("%") replace
label var perc_black "%Black State Adult Pop."
tab perc_black

*Drop non-white respondents or those who did not answer main IV questions
drop if white_non_hispanic !=1
drop if stereo_black_violent ==. & stereo_white_violent ==. & stereo_violent_black_diff3 ==. & stereo_lazy_black_diff3 ==.

save "Coll Stereotypes Threat White Disenfranchisement Support Data Cleaned.dta", replace